﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using CarolLib.Extension;

namespace DCS.Business.Model
{
    /// <summary>
    /// DCSFile
    /// </summary>
    public class DCSFile
    {
        /// <summary>
        /// DCSFile 构造函数
        /// </summary>
        public DCSFile()
        { }

        /// <summary>
        /// DCSFile OR映射构造函数
        /// </summary>
        public DCSFile(System.Data.IDataReader dr)
        {
            this.FileId = Convert.ToInt32(dr["FileId"]);
            this.RemoteFileName = Convert.ToString(dr["RemoteFileName"]);
            this.RemotePath = Convert.ToString(dr["RemotePath"]);
            this.LocalFileName = Convert.ToString(dr["LocalFileName"]);
            this.LocalPath = Convert.ToString(dr["LocalPath"]);
            this.Size = Convert.ToDecimal(dr["Size"]);
            this.MessageType = Convert.ToString(dr["MessageType"]);
            this.Status = (FileStatus)Convert.ToInt32(dr["Status"]);
            this.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
            this.DetectTime = Convert.ToDateTime(dr["DetectTime"]);
            this.DownloadTime = Convert.ToDateTime(dr["DownloadTime"]);
            this.ParseStartTime = Convert.ToDateTime(dr["ParseStartTime"]);
            this.ParseFinishTime = Convert.ToDateTime(dr["ParseFinishTime"]);
            this.ResultId = (Guid)dr["ResultId"];
        }

        /// <summary>
        /// 文件Id
        /// </summary>
        public int FileId { get; set; }

        /// <summary>
        /// 远程文件名
        /// </summary>
        public string RemoteFileName { get; set; }

        /// <summary>
        /// 远程路径
        /// </summary>
        public string RemotePath { get; set; }

        /// <summary>
        /// 本地文件名
        /// </summary>
        public string LocalFileName { get; set; }

        /// <summary>
        /// 本地路径
        /// </summary>
        public string LocalPath { get; set; }

        /// <summary>
        /// 文件大小
        /// </summary>
        public decimal Size { get; set; }

        /// <summary>
        /// 信息类型
        /// </summary>
        public string MessageType { get; set; }

        /// <summary>
        /// 报文状态
        /// </summary>
        public FileStatus Status { get; set; }

        /// <summary>
        /// 文件创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 检测到该报文的时间
        /// </summary>
        public DateTime DetectTime { get; set; }

        /// <summary>
        /// 报文下载时间
        /// </summary>
        public DateTime? DownloadTime { get; set; }

        /// <summary>
        /// 报文开始解析时间
        /// </summary>
        public DateTime? ParseStartTime { get; set; }

        /// <summary>
        /// 报文完成解析时间
        /// </summary>
        public DateTime? ParseFinishTime { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? ResultId { get; set; }

        /// <summary>
        /// 部分号
        /// </summary>
        public int PartNo
        {
            get
            {
                int start = RemoteFileName.IndexOf("_PART") + 5;
                return RemoteFileName.Substring(start, RemoteFileName.IndexOf(".txt") - start).TryToInt();
            }
        }
    }
}




